package com.jasonchoi.rabbitmq.controller;

import com.jasonchoi.rabbitmq.producter.TestProducter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: JasonChoi
 * @Date: 2020/5/28 16:35
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private TestProducter testProducter;

    @GetMapping("/direct/send")
    public String senddirectMessage(@RequestParam String msg){
        testProducter.directSend(msg);
        return "ok";
    }

    @GetMapping("/topic/send")
    public String sendMessage(@RequestParam String msg, @RequestParam(required = false) boolean broadcast) {
        testProducter.topicSend(msg,broadcast);
        return "ok";
    }

    @GetMapping("/fanout/send")
    public String sendMessage(@RequestParam String msg) {
        testProducter.fanoutSend(msg);
        return "ok";
    }
}
